package ttest;

import timeDivisionMultipleAccess.TimeSyncer;

public class TestTimeSyncer {

    public static void main(String[] args) {
        long accTime = 0;
        long accDelay = 0;
        long dispatchDelay = 2;
        long arrivalDelay = 6;
        TimeSyncer syncer = new TimeSyncer();

        // Test first message
        System.out.println("System time: " + System.currentTimeMillis());

        accTime = syncer.getCurrentTime();
        System.out.println("Sync time: " + accTime);

        syncer.syncTime(accTime + dispatchDelay, accTime + arrivalDelay);

        System.out.println("Sync time: " + syncer.getCurrentTime());

        accDelay = syncer.getCurrentTime() - accTime;

        System.out.println("Sync delay: " + accDelay);

        // Test second message
        syncer.syncTime(accTime + 8, accTime + 10);

        System.out.println("Sync time: " + syncer.getCurrentTime());

        accDelay = syncer.getCurrentTime() - accTime;

        System.out.println("Sync delay: " + accDelay);

        
        System.out.println("Next Slot: " + accTime / 1000 % 1000);
    }

}
